#include "utils.h"
#include <cmath>

USING_NS_CC;

long TimeUtil::getTimer()
{
	timeval time; 
	gettimeofday(&time, NULL); 
	return (time.tv_sec * 1000) + (time.tv_usec / 1000); 
}

const float MathUtil::PI = 3.141593f;

float MathUtil::getDistance(float x0, float y0, float x1, float y1)
{
	float x = abs(x0 - x1);
	float y = abs(y0 - y1);
	return sqrt(x * x + y * y);
}

float MathUtil::getRadian(float x, float y)
{
	return atan2(y, x);
}

float MathUtil::getRadian2(float orginX, float orginY, float descX, float descY)
{
	float x = descX - orginX;
	float y = descY - orginY;
	return getRadian(x, y);
}

float MathUtil::radian2Angle(float radian)
{
	return radian * 180.0f / PI;
}

float MathUtil::angle2Radian(float angle)
{
	return angle * PI / 180.0f;	
}
